﻿using System;
using System.Collections;
using System.Collections.Generic;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using ENT.GP.Core;
using ENT.GP.Core.Core;
using ENT.GP.Core.Lookup;
using ENT.GP.Core.Proyecto;
using entgp.Code;
using Ext.Net;
using entgp.ServiceGetDataDropBoxExcel;

//using entgp.ServiceRefGetDat;
public partial class ViewDocExcel : PaginasUsuario
{

    DataSet proyectos = new DataSet();
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {

          
        }
    }
    /// <summary>
    /// Invoca metodo para actualizar datos de la grid
    /// </summary>
    private static void CallRefreshGrid()
    {
       
    }
    protected void StoreRefresh(object sender, StoreRefreshDataEventArgs e)
    {

    }

    protected void EjecutarAccion(object sender, DirectEventArgs e)
    {
        try
        {
           
        }
        catch (Exception ex)
        {
            Util.RegistarLog(ex.ToString());
        }

    }

    public void btnBuscar_Click(object sender, DirectEventArgs e)
    {
        try
        {

            ServiceGetDataDropBoxClient client = new ServiceGetDataDropBoxClient();
            RootObject rta = client.GetData(cbxAnyo.SelectedItem.Value, cbxMes.SelectedItem.Value);
            List<object> data = new List<object>();
            if (rta.info.listExcel.Length!=0)
            {
                data = new List<object>(rta.info.listExcel.Length);
                List<object> ItemInfo = new List<object>(rta.info.listExcel.Length);
                for (int i = 1; i < rta.info.listExcel.Length; i++)
                {
                    var item = rta.info.listExcel[i];
                    ItemInfo.Add(new
                    {
                        Mes     =item.Mes,
                        Ingreso = item.Ingreso.ToString(),
                        Egreso = item.Egreso.ToString(),
                        Saldo = item.Saldo.ToString()
                       
                    });
                    
                }
                if (rta.info.listExcel.Length != 1)
                    data.Add(new { Letter = "", Item = ItemInfo });

                var itemTotal = rta.info.listExcel[0];
                ItemInfo = new List<object>(1);
                ItemInfo.Add(new
                {
                    Mes = itemTotal.Mes,
                    Ingreso = itemTotal.Ingreso.ToString(),
                    Egreso = itemTotal.Egreso.ToString(),
                    Saldo = itemTotal.Saldo.ToString()

                });
                data.Add(new { Letter = " ", Item = itemTotal });
            }
            this.dsReport.DataSource = data;
            this.dsReport.DataBind();
            client.Close();

          
        }
        catch (Exception ex)
        {
            Util.RegistarLog(ex.ToString());
        }
    }
}
